home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Text⁄Files / Dialectic 1.1 Source / Dialectic ƒ / Dialectic code / dialectic utilities.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-14  |  2.4 KB  |  101 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        dialectic utilities.c
  4.  
  5. Purpose:    This module contains various utilities which the raw
  6.             dialect routines use in converting text.
  7.             
  8.  
  9.  
  10. Dialectic -=- dialect text conversion extraordinare
  11. Copyright ©1994, Mark Pilgrim
  12.  
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License, or
  16. (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program in a file named "GNU General Public License".
  25. If not, write to the Free Software Foundation, 675 Mass Ave,
  26. Cambridge, MA 02139, USA.
  27.  
  28. \**********************************************************************/
  29.  
  30. #include "dialectic utilities.h"
  31. #include "program globals.h"
  32.  
  33. Boolean IsAlpha(char thisChar)
  34. {
  35.     return ((((thisChar|0x20)>='a') && ((thisChar|0x20)<='z')) || (thisChar==0x27) ||
  36.             (thisChar=='’'));
  37. }
  38.  
  39. Boolean IsUpperAlpha(char thisChar)
  40. {
  41.     return (((thisChar>='A') && (thisChar<='Z')) || (thisChar==0x27) || (thisChar=='’'));
  42. }
  43.  
  44. Boolean IsNumeric(char thisChar)
  45. {
  46.     return ((thisChar>='0') && (thisChar<='9'));
  47. }
  48.  
  49. Boolean IsVowel(char thisChar)
  50. {
  51.     char        lowerChar;
  52.     
  53.     lowerChar=thisChar|0x20;
  54.     return ((lowerChar=='a') || (lowerChar=='e') || (lowerChar=='i') ||
  55.             (lowerChar=='o') || (lowerChar=='u'));
  56. }
  57.  
  58. Boolean IsConsonant(char thisChar)
  59. {
  60.     return (IsAlpha(thisChar) && (!IsVowel(thisChar)));
  61. }
  62.  
  63. char ThisChar(void)
  64. {
  65.     if (gInputOffset>=INPUT_BUFFER_MAX)
  66.         gInputNeedsUpdate=TRUE;
  67.     if (gAbsoluteOffset>=gInputLength)
  68.         return 0x00;
  69.     else
  70.         return *((char*)((long)gInputBuffer+gInputOffset));
  71. }
  72.  
  73. char NextChar(int howmany)
  74. {
  75.     if (gAbsoluteOffset+howmany>=gInputLength)
  76.         return 0x00;
  77.     else
  78.         return *((char*)((long)gInputBuffer+gInputOffset+howmany));
  79. }
  80.  
  81. void StoreChar(char thisChar)
  82. {
  83.     *((char*)((long)gOutputBuffer+(gOutputOffset++)))=thisChar;
  84.     if (gOutputOffset>=OUTPUT_BUFFER_MAX)
  85.         gOutputNeedsUpdate=TRUE;
  86. }
  87.  
  88. void StoreString(Str255 thisString)
  89. {
  90.     int                i;
  91.     
  92.     for (i=1; i<=thisString[0]; i++)
  93.         StoreChar(thisString[i]);
  94. }
  95.  
  96. void InputPlus(int howmany)
  97. {
  98.     gInputOffset+=howmany;
  99.     gAbsoluteOffset+=howmany;
  100. }
  101.